import  pandas as pd
import copy

path_data1 = pd.read_excel(r'C:\Users\86191\Desktop\学院.xlsx')
path_data2 = pd.read_excel(r'C:\Users\86191\Desktop\湖大各院坐标.xlsx')
lenth = len(path_data2['学院名称'])
name = list(path_data2['学院名称'])
data = list(path_data1['distance'])

df = [[0 for i in range(lenth)] for j in range(lenth)]
j = 0
k = 0
for i in range(len(data)):
    if k == lenth:
        j += 1
        k = 0
    df[j][k] = data[i]
    k += 1

df = pd.DataFrame(df, columns=name, index=name)
writer = pd.ExcelWriter(r'C:\Users\86191\Desktop\湖大各学院距离矩阵.xls', engine='xlsxwriter')
df.to_excel(writer, sheet_name='湖大各学院距离矩阵')
writer._save()
writer.close()
